#include <MapKit/MKTriangle.h>

MKTriangle::MKTriangle()
{
}

MKTriangle::~MKTriangle()
{
}

MKTriangle* MKTriangle::Create()
{
    return new MKTriangle;
}

void MKTriangle::Destroy()
{
    delete this;
}

void MKTriangle::Sort()
{
    if (*A < *B && *B < *C)
        ;
    else if (*A < *C && *C < *B)
    {
        MKVertex* t = B;
        B = C;
        C = t;
    }
    else if (*B < *A && *A < *C)
    {
        MKVertex* t = A;
        A = B;
        B = A;
    }
    else if (*B < *C && *C < *A)
    {
        MKVertex* t = A;
        A = B;
        B = C;
        C = t;
    }
    else if (*C < *A && *A < *B)
    {
        MKVertex* t = C;
        C = B;
        B = A;
        A = t;
    }
    else if (*C < *B && *B < *A)
    {
        MKVertex* t = A;
        A = C;
        C = t;
    }
}

bool MKTriangle::operator==(const MKTriangle& tri) const
{
    return A == tri.A && B == tri.B && C == tri.C;
}

bool MKTriangle::operator!=(const MKTriangle& tri) const
{
    return !(*this == tri);
}

bool MKTriangle::operator<(const MKTriangle& tri) const
{
    if (A != tri.A)
        return A < tri.A;
    else if (B != tri.B)
        return B < tri.B;
    else
        return C < tri.C;
}

bool MKTriangle::operator<=(const MKTriangle& tri) const
{
    return !(*this > tri);
}

bool MKTriangle::operator>(const MKTriangle& tri) const
{
    if (A != tri.A)
        return A > tri.A;
    else if (B != tri.B)
        return B > tri.B;
    else
        return C > tri.C;
}

bool MKTriangle::operator>=(const MKTriangle& tri) const
{
    return !(*this < tri);
}